package com.nobleoxtechnology.weatherSMS;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;

public class Settings implements AdapterView.OnItemClickListener
{
	private Context context;
	private Activity activity;
	private SharedPreferences preferences;
	private weatherSMS w;
	
	public Settings(Context context, Activity activity, SharedPreferences preferences, weatherSMS w)
	{
		this.context = context;
		this.activity = activity;
		this.preferences = preferences;
		this.w = w;
	}
	
	@Override
	public void onItemClick(AdapterView<?> a, View v, int position, final long out_id)
	{
		switch ((int) out_id)
		{
		// General
		case 0:
			activity.setContentView(R.layout.general);
			activity.setTitle("weatherSMS - General Settings");
			
			w.treeBranch = 2;
			
			Button applyButtonG = (Button) activity.findViewById(R.id.buttonApply);
			applyButtonG.setOnClickListener(new GeneralSettings(context, activity, preferences));
			break;
			
		// Message Parsing
		case 1:
			activity.setContentView(R.layout.message_parsing);
			activity.setTitle("weatherSMS - Message Parsing");
			w.treeBranch = 2;
		        
			Button applyButtonMP = (Button) activity.findViewById(R.id.buttonApply);
			applyButtonMP.setOnClickListener(new MessageParsing(context, activity, preferences));
			break;
			
		// Advanced
		case 2:
			activity.setContentView(R.layout.advanced);
			activity.setTitle("weatherSMS - Advanced Settings");
			w.treeBranch = 2;
		        
			Button applyButtonA = (Button) activity.findViewById(R.id.buttonApplyA);
			applyButtonA.setOnClickListener(new AdvancedSettings(context, activity, preferences));
			break;
		}
	}
}
